<template>
  <table>
    <tr>
        <td>房型名称</td>
        <td>
            <input type="text" v-model="info.R_fangxin" placeholder="请输入房型名称">
        </td>
    </tr>
    <tr>
        <td>房号</td>
        <td>
            <input type="text" v-model="info.R_Name" placeholder="请输入房号">
        </td>
    </tr>
    <tr>
        <td>状态</td>
        <td>
            <input type="radio"  :value="true" v-model="info.R_Status">启用
            <input type="radio" :value="false" v-model="info.R_Status">禁用
        </td>
    </tr>
    <tr>
        <td>备注</td>
        <td>   
            <input type="text" v-model="info.R_BeiZhu" placeholder="请输入备注">
        </td>
    </tr>
    <tr>
        <td></td>
        <td>
            <input type="button" value="添加" @click="save" >
        </td>
    </tr>
  </table>
</template>

<script setup lang="ts">
import {onMounted, ref} from 'vue'
import axios from 'axios'
import { useRouter } from 'vue-router';


const user=useRouter();

const info=ref({
"R_fangxin": "",
"R_Name": "",
"R_Status": true,
"R_BeiZhu": "",
"R_Biblio": true

})
const  save=()=>{
    axios.post("https://localhost:7285/api/Roomnumber/AddNumber",info.value)
    .then(res=>{
        if(res.data>0){
            alert("添加成功");
            user.push("/ShowNumber")
        }else if(res.data==-1){
            alert("重复添加");
        }else{
            alert("添加失败");
        }
    })
}
</script>

<style scoped>

</style>